package com.softer.wxzj.mapper;

import com.softer.wxzj.entity.AccKeepAccount;
import com.softer.wxzj.entity.SettleAccounts;
import com.softer.wxzj.mapper.base.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface AccKeepAccountMapper extends BaseMapper<AccKeepAccount> {
    /**
     * 交易信息查询列表
     *
     * @param accKeepAccount
     * @return
     */
    List<AccKeepAccount> getTransInfoList(AccKeepAccount accKeepAccount);

    /**
     * 交易信息查询金额总计
     *
     * @return
     */
    AccKeepAccount getTransInfoTotal(AccKeepAccount accKeepAccount);

    /**
     * 业务编号下拉列表
     *
     * @return
     */
    List<AccKeepAccount> getPayNo(AccKeepAccount accKeepAccount);

    /**
     * 查询最大的承办银行的时间
     */
    String selectMaxSettlementTime(String bankCode);

    /**
     * 查询列表
     *
     * @param id
     * @return
     */
    AccKeepAccount selectAndGetInfo(String id);

    /**
     * 模糊查询
     *
     * @param fuzzy
     * @return
     */
    List<AccKeepAccount> fuzzyGetList(@Param("fuzzy") String fuzzy, @Param("bankCode") String bankCode, @Param("zoneCode") String zoneCode, @Param("accountState") String accountState);

    AccKeepAccount getListInfo(String id);

    /**
     * 通过reqId查询keep这条数据状态为正常
     *
     * @param reqId
     * @return
     */
    AccKeepAccount selectCountByReqId(String reqId);

    /**
     * 修改状态
     *
     * @param state
     * @param payNo
     * @return
     */
    int updateState(@Param("state") String state, @Param("payNo") String payNo);

    /**
     * 票据上传的模糊查询
     *
     * @param fuzzy
     * @param bankCode
     * @param zoneCode
     * @return
     */
    List<AccKeepAccount> fuzzyGetListAndBusiNo(@Param("fuzzy") String fuzzy, @Param("bankCode") String bankCode, @Param("zoneCode") String zoneCode, @Param("billState") String billState, @Param("accountState") String accountState);

    List<AccKeepAccount> getListByBankCodeAndTallyTime(AccKeepAccount accKeepAccount);

    /**
     * 核对条件
     *
     * @param bankId
     * @param tallyTimeStart
     * @param tallyTimeEnd
     * @return
     */
    List<SettleAccounts> getCountList(@Param("bankCode") String bankId, @Param("tallyTimeStart") String tallyTimeStart, @Param("tallyTimeEnd") String tallyTimeEnd);

    /**
     * 核对总计
     *
     * @param bankId
     * @param tallyTimeStart
     * @param tallyTimeEnd
     * @return
     */
    SettleAccounts getCountListSum(@Param("bankCode") String bankId, @Param("tallyTimeStart") String tallyTimeStart, @Param("tallyTimeEnd") String tallyTimeEnd);

    /**
     * 查询该时间有没有未核对的数据
     *
     * @param bankCode
     * @param tallyTime
     * @return
     */
    List<AccKeepAccount> selectState(@Param("bankCode") String bankCode, @Param("tallyTime") String tallyTime);

    /**
     * 记账修改状态
     *
     * @param id
     * @param accountState
     * @return
     */
    int updateAccState(@Param("id") String id, @Param("accountState") String accountState, @Param("tallyTime") String tallyTime);

    /**
     * 日终核对---批量结算查询收入支付 （金额，笔数）
     *
     * @param bankCode       银行id
     * @param tallyTimeStart 开始时间（结算时间）
     * @param tallyTimeEnd   结算时间（最大当天时间）
     * @return 返回  SettleAccounts 实体
     */
    SettleAccounts batchSettlementInquiry(@Param("bankCode") String bankCode, @Param("tallyTimeStart") String tallyTimeStart, @Param("tallyTimeEnd") String tallyTimeEnd);

    /**
     * 日终核对---批量结算--确定结算
     *
     * @param bankCode       银行id
     * @param tallyTimeStart 开始时间（结算时间）
     * @param tallyTimeEnd   结算时间（最大当天时间）
     * @return 返回  int
     */
    int settlement(@Param("bankCode") String bankCode, @Param("tallyTimeStart") String tallyTimeStart, @Param("tallyTimeEnd") String tallyTimeEnd);


    List<AccKeepAccount> getListByBankCodeAndTallyTimeFuzzy(AccKeepAccount accKeepAccount);

    BigDecimal getListByBankCodeAndTallyTimeFuzzySum(AccKeepAccount accKeepAccount);

    /**
     * 查询已记账的业务编号
     */
    List<AccKeepAccount> selectBusiNo();

    /**
     * 精确查询 根据Module 总计
     *
     * @param accKeepAccount
     * @return
     */
    BigDecimal getListSumPayAmount(AccKeepAccount accKeepAccount);

    BigDecimal getListSumPayAmountAdd(AccKeepAccount accKeepAccount);

    /**
     * 记账展示类表模糊查询 金额总计
     *
     * @param fuzzy
     * @param bankCode
     * @param zoneCode
     * @return
     */
    BigDecimal fuzzyGetListSumPayAmount(@Param("fuzzy") String fuzzy, @Param("bankCode") String bankCode, @Param("zoneCode") String zoneCode, @Param("accountState") String accountState);

    BigDecimal fuzzyGetListSumPayAmountAdd(@Param("fuzzy") String fuzzy, @Param("bankCode") String bankCode, @Param("zoneCode") String zoneCode, @Param("accountState") String accountState);

    /**
     * 票据上传 模糊查询 金额总计
     *
     * @param fuzzy
     * @param bankCode
     * @param zoneCode
     * @return
     */
    BigDecimal fuzzyGetListAndBusiNoSumPayAmount(@Param("fuzzy") String fuzzy, @Param("bankCode") String bankCode, @Param("zoneCode") String zoneCode, @Param("accountState") String accountState, @Param("billState") String billState);

    BigDecimal fuzzyGetListAndBusiNoSumPayAmountAdd(@Param("fuzzy") String fuzzy, @Param("bankCode") String bankCode, @Param("zoneCode") String zoneCode, @Param("accountState") String accountState, @Param("billState") String billState);

    /**
     * 修改承办银行的金额
     *
     * @param bankId
     * @param payAmount
     * @return
     */
    int updateBankMoney(@Param("bankId") String bankId, @Param("payAmount") BigDecimal payAmount);

    /**
     * 核对
     *
     * @param state
     * @param checkTime
     * @param checkOper
     * @param id
     * @return
     */
    int check(@Param("state") String state, @Param("checkTime") String checkTime, @Param("checkOper") String checkOper, @Param("id") String id);

    /**
     * 核对合计
     *
     * @param accKeepAccount
     * @return
     */
    BigDecimal getListByBankCodeAndTallyTimeSum(AccKeepAccount accKeepAccount);

    /**
     * 修改有效期日期
     *
     * @param id
     * @param vaildDate
     * @return
     */
    int updateVaildDateByNo(@Param("id") String id, @Param("vaildDate") String vaildDate);

    /**
     * 根据业务编号更新有效日期
     *
     * @param accKeepAccount 修改实体
     * @return 修改结果
     */
    int updateValidDate(AccKeepAccount accKeepAccount);

    /**
     * 通过业务编号查询id
     *
     * @param busiNo 业务编号
     * @return id
     */
    String selectByPayNo(String busiNo);

    /**
     * 是有否银行
     *
     * @param bankId
     * @param tallyTimeStrat
     * @return
     */
    int selectByAcc(@Param("bankId") String bankId, @Param("tallyTimeStrat") String tallyTimeStrat);

    int selectNotByAcc(@Param("bankId") String bankId, @Param("tallyTimeStrat") String tallyTimeStrat);

    int deleteByBusiNo(@Param("payNo") String payNo);

    /**
     * 查询有没有
     *
     * @param busiNo
     * @return
     */
    int selectCountByNo(String busiNo);

    /**
     * @param tallyTimeNow 记账日期
     * @return
     */
    int selectSelByHouse(@Param("tallyTimeNow") String tallyTimeNow, @Param("bankCode") String bankCode);

    List<AccKeepAccount> selectByBusi(@Param("bankCode") String bankCode, @Param("tallyTimeStart") String tallyTimeStart, @Param("tallyTimeEnd") String tallyTimeEnd, @Param("busiType") String busiType);

    int settlementOne(@Param("bankCode") String bankCode, @Param("tallyTimeEnd") String tallyTimeEnd);
}
